package com.ruoyi.project.query.paeaDsInvm.controller;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.query.paeaDsInvm.domain.PaeaDsInvm;
import com.ruoyi.project.query.paeaDsInvm.service.IPaeaDsInvmService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import java.util.Arrays;

import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 账户Controller
 *
 * @author ruoyi
 * @date 2020-04-06
 */
@Controller
@RequestMapping("/query/paeaDsInvm")
public class PaeaDsInvmController extends BaseController
{
    private String prefix = "query/paeaDsInvm";

    @Autowired
    private IPaeaDsInvmService paeaDsInvmService;

    @RequiresPermissions("query:paeaDsInvm:view")
    @GetMapping()
    public String paeaDsInvm()
    {
        return prefix + "/paeaDsInvm";
    }

    /**
     * 查询账户列表
     */
    @RequiresPermissions("query:paeaDsInvm:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaDsInvm paeaDsInvm)
    {
        startPage();
        List<PaeaDsInvm> list = paeaDsInvmService.list(new QueryWrapper<>(paeaDsInvm));
        return getDataTable(list);
    }

    /**
     * 导出账户列表
     */
    @RequiresPermissions("query:paeaDsInvm:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaeaDsInvm paeaDsInvm)
    {
        List<PaeaDsInvm> list = paeaDsInvmService.list(new QueryWrapper<>(paeaDsInvm));
        ExcelUtil<PaeaDsInvm> util = new ExcelUtil<PaeaDsInvm>(PaeaDsInvm.class);
        return util.exportExcel(list, "paeaDsInvm");
    }

    /**
     * 新增账户
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存账户
     */
    @RequiresPermissions("query:paeaDsInvm:add")
    @Log(title = "账户", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaeaDsInvm paeaDsInvm)
    {
        return toAjax(paeaDsInvmService.saveOrUpdate(paeaDsInvm));
    }

    /**
     * 修改保存账户
     */
    @RequiresPermissions("query:paeaDsInvm:edit")
    @Log(title = "账户", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaeaDsInvm paeaDsInvm)
    {
        return toAjax(paeaDsInvmService.saveOrUpdate(paeaDsInvm));
    }

    /**
     * 删除账户
     */
    @RequiresPermissions("query:paeaDsInvm:remove")
    @Log(title = "账户", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paeaDsInvmService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
